package com.cssl.gulimall.search.controller;

import com.cssl.common.vo.search.SearchParam;
import com.cssl.common.vo.search.SearchResult;
import com.cssl.gulimall.search.service.MallSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

@Controller
public class SearchController {
    @Autowired
    private MallSearchService searchService;

    @RequestMapping("/list.html")
    public String list(SearchParam searchParam, Model model, HttpServletRequest request){
        searchParam.set_queryString(request.getQueryString());
        SearchResult result = searchService.search(searchParam);
        model.addAttribute("result",result);
        return "list";
    }
}
